﻿#ifndef STAGECONTROLDOCKWIDGET_H
#define STAGECONTROLDOCKWIDGET_H

#include <QtWidgets/QVBoxLayout>
#include <QtWidgets/QDockWidget>
#include "XYControlGroupBox.h"
#include "ZControlGroupBox.h"
#include "PositionGroupBox.h"

class StageControlDockWidget : public QDockWidget
{
    Q_OBJECT
public:
    StageControlDockWidget(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags());
    void initContent();
    void initConnection();

public slots:
    void xySpeedUp();
    void xySpeedDown();
    void zSpeedUp();
    void zSpeedDown();

    void joystick_moveUp();
    void joystick_moveDown();
    void joystick_moveForward();
    void joystick_moveBackward();
    void joystick_moveLeft();
    void joystick_moveRight();
    void setXPosition(double x);
    void setYPosition(double y);
    void setZPosition(double z);
    void setPosition(double x, double y, double z);

    void enableXYControl(bool on);
    void enableGoHome(bool on);
signals:
    void moveForward(double mmps);
    void moveBackward(double mmps);
    void moveLeft(double mmps);
    void moveRight(double mmps);

    void moveForwardStop();
    void moveBackwardStop();
    void moveLeftStop();
    void moveRightStop();
    void moveUp(double mmps);
    void moveDown(double mmps);
    void moveUpStop();
    void moveDownStop();
    void stopXY();
    void stopZ();

    void goHomeX();
    void goHomeY();
    void goHomeZ();
    void goHome();

    void changeXYSpeed(double mmps);
    void changeZSpeed(double mmps);

    void autoFocus();    

private:
    XYControlGroupBox *xyControl;
    ZControlGroupBox *zControl;
    PositionGroupBox *xyPosGB;

    QPushButton *pushButtonGoHomeX;
    QPushButton *pushButtonGoHomeY;
    QPushButton *pushButtonGoHomeZ;

    QVBoxLayout *goHomeLayout;
    QGroupBox *goHomeGroupBox;

    QHBoxLayout *horizontalLayout;
    QWidget *dockWidget;
    QVBoxLayout *vLayout;
};

#endif // STAGECONTROLDOCKWIDGET_H
